﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWork1
{
    class Program
    {
        static void Main(string[] args)
        {
            FindMinMaxElementOfArray();
        }

        static void InputPlus10()
        {
            int input;
            bool result = Int32.TryParse(Console.ReadLine(), out input);
            if (result)
            {
                input = Int32.Parse(Console.ReadLine());
                Console.WriteLine(input + 10);
            }
        }

        static void InputPlusN()
        {
            int n;

            bool result = Int32.TryParse(Console.ReadLine(), out n);

            if (result & n > 0)
            {
                int sum = 0;
                for (int i = 1; i <= n; i++)
                {
                    sum = sum + i;
                }
                Console.WriteLine(sum);
            }
            else
            {
                Console.WriteLine("Error");
            }
        }

        static void GetDistance()
        {
            double x1 = Double.Parse(Console.ReadLine());
            double y1 = Double.Parse(Console.ReadLine());
            double x2 = Double.Parse(Console.ReadLine());
            double y2 = Double.Parse(Console.ReadLine());

            double distance = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
            Console.WriteLine(distance);
        }

        static void GetQuarterFromInput()
        {
            double x = Double.Parse(Console.ReadLine());
            double y = Double.Parse(Console.ReadLine());

            if (x > 0 & y > 0)
            {
                Console.WriteLine("I");
            }
            else if (x < 0 & y > 0)
            {
                Console.WriteLine("II");
            }
            else if (x < 0 & y < 0)
            {
                Console.WriteLine("III");
            }
            else if (x > 0 & y < 0)
            {
                Console.WriteLine("IV");
            }
            else if (x == 0 & y > 0)
            {
                Console.WriteLine("Axis Y+");
            }
            else if (x == 0 & y < 0)
            {
                Console.WriteLine("Axis Y-");
            }
            else if (x > 0 & y == 0)
            {
                Console.WriteLine("Axis X+");
            }
            else if (x < 0 & y == 0)
            {
                Console.WriteLine("Axis X-");
            }
            else
            {
                Console.WriteLine("Center");
            }
        }

        static void PrintFrame(int width, int height, char frameBlock)
        {
            // Print frame top
            for (int i = 0; i < width; i++)
            {
                Console.Write(frameBlock);
            }
            Console.WriteLine();

            // Print frame center
            int count = 0;
            do
            {
                for (int j = 0; j < 1; j++)
                {
                    Console.Write(frameBlock);
                    for (int k = 0; k < width - 2; k++)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(frameBlock);
                }
                Console.WriteLine();
                count++;
            } while (count < height - 2);

            // Print frame bottom
            for (int i = 0; i < width; i++)
            {
                Console.Write(frameBlock);
            }
        }


        static int[] FillArray(int arraySize)
        {
            int[] array = new int[arraySize];
            Random rnd = new Random();
            for (int i = 0; i < arraySize; i++)
            {
                array[i] = rnd.Next(1, 1000);
            }
            return array;
        }

        static void CountEvenOddMemberOfArray()
        {
            int[] array = new int[5];
            Random rnd = new Random();
            int even = 0;
            int odd = 0;
            for (int i = 0; i < 5; i++)
            {
                array[i] = rnd.Next(1, 1000);
                Console.WriteLine(array[i]);
                if (array[i]%2 == 0)
                {
                    even++;
                }
                else
                {
                    odd++;
                }
            }
            Console.WriteLine("Even: {0}", even);
            Console.WriteLine("Odd: {0}", odd);
        }

        static void FindMinMaxElementOfArray()
        {
            int[] array = new int[20];
            Random rnd = new Random();
            int maxValue = Int32.MinValue;
            int minValue = Int32.MaxValue;
            int maxValueCount = 0;
            int minValueCount = 0;
            for (int i = 0; i < 5; i++)
            {
                array[i] = rnd.Next(1, 10);
                Console.WriteLine(array[i]);
                
                // Find max value
                if (array[i] > maxValue)
                {
                    maxValue = array[i];
                }
                // Find min value
                if (array[i] < minValue)
                {
                    minValue = array[i];
                }
            }

            for (int j = 0; j < 5; j++)
            {
                if (maxValue == array[j])
                {
                    Console.WriteLine("First index of max value {0}", j + 1);
                    break;
                }
            }

            for (int k = 0; k < 5; k++)
            {
                if (minValue == array[k])
                {
                    Console.WriteLine("First index of min value {0}", k + 1);
                    break;
                }
            }

            for (int m = 0; m < 5; m++)
            {
                if (maxValue == array[m])
                {
                    maxValueCount++;
                }
                else if (minValue == array[m])
                {
                    minValueCount++;
                }
            }
            Console.WriteLine("Amount of max value: {0}. Amount of min value {1}", maxValueCount, minValueCount);
            //Console.WriteLine("Max: {0}", maxValue);
            //Console.WriteLine("Min: {0}", minValue);

        }
    }
}